feat: add AllocEvent and FreeEvent to trace format#420
Merged
Conversation
Adds wire-format definitions for sampled allocation and matching free
events
that the upcoming memory profiler will emit. Per design §3:
- AllocEvent { timestamp_ns, tid, size, addr, callchain }
- FreeEvent { timestamp_ns, tid, addr, size, alloc_timestamp_ns }
`size` and `alloc_timestamp_ns` are denormalized onto FreeEvent so leak
analysis stays useful when the matching AllocEvent has been evicted by
trace
rotation.
This is the schema only — no producer (allocator hook) and no UI
flamegraph
yet. Both will land in later commits per the rollout in design §15.
Demo trace not regenerated: there is no producer of these events yet.
c791bfc to
90b35b2
Compare
yulnr
approved these changes
May 18, 2026
Collaborator
yulnr
left a comment
There was a problem hiding this comment.
Looks good!
Side note: I wonder if we eventually want to make TelemetryEvent #[non_exhaustive]. Though I guess often new additions here mean breaking changes either way, and perhaps for the analysis tool you would like to be aware of new events rather than skip them.
Contributor
Author
|
yeah we definitely want to make that |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds wire-format definitions for sampled allocation and matching free events that the upcoming memory profiler will emit. Per design §3:
AllocEvent { timestamp_ns, tid, size, addr, callchain }FreeEvent { timestamp_ns, tid, addr, size, alloc_timestamp_ns }sizeandalloc_timestamp_nsare denormalized ontoFreeEventso leak analysis stays useful when the matchingAllocEventhas been evicted by trace rotation.This is the schema only — no producer (allocator hook) and no UI flamegraph yet. Both will land in follow-up PRs (ring-buffer scaffold,
Dial9Allocatorwrapper,MemoryProfiler::install, hook wiring) per the rollout in design §15.API shape
Both events are gated on
#[cfg_attr(not(feature = "unstable-events"), non_exhaustive)]. By default (no feature) they cannot be constructed by downstream crates, so adding fields later is non-breaking. Crates that need to construct them directly (e.g. for tests or custom event injection) opt in tounstable-eventsand accept that new fields may break them.Backwards compatibility
Per AGENTS.md trace-format rules: this PR only adds new event types. Old traces don't contain
AllocEvent/FreeEvent, the JS decoder gracefully no-ops on missing schemas, and we don't need old Rust decoders to read new traces.Demo trace
Not regenerated — there is no producer of these events yet.
Verification
cargo fmt --check: cleancargo clippy --all-targets --all-features: cleancargo nextest run: 594/594 passedcargo nextest run --stress-duration 20s: 2 iterations × 594/594 passed